package com.zmn.oms.business.impl.servtype;

import com.zmn.oms.common.constant.OrderConsts;
import com.zmn.oms.manager.utils.SpringContextUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @ClassName ServTypeTemplateFactory
 * @description:
 * @author: wangyanci
 * @create: 2021-11-26 18:10
 * @Version 1.0
 **/
public class ServItemTemplateFactory {

    private static final Map<Integer, Class<? extends AbstractServItemService>> servTypeBServiceMap = new HashMap<>();

    static {
        servTypeBServiceMap.put(OrderConsts.SERVICE_ITEM_TYPE_ORDER, BeforeQuotationThreeServTypeServiceImpl.class);
        servTypeBServiceMap.put(OrderConsts.SERVICE_ITEM_TYPE_FAULT, BeforeQuotationThreeServTypeServiceImpl.class);
        servTypeBServiceMap.put(OrderConsts.SERVICE_ITEM_TYPE_ADVANCE_PAY, BeforeQuotationThreeServTypeServiceImpl.class);
        servTypeBServiceMap.put(OrderConsts.SERVICE_ITEM_TYPE_QUOTATION_THREE, QuotationThreeServTypeServiceImpl.class);
        servTypeBServiceMap.put(OrderConsts.SERVICE_ITEM_TYPE_FINAL_PRICE, FinalPriceServTypeServiceImpl.class);
    }

    public static AbstractServItemService getTemplateService(Integer servType) {
        Class<? extends AbstractServItemService> serviceClass = servTypeBServiceMap.get(servType);
        if (Objects.isNull(serviceClass)) {
            return null;
        }
        return SpringContextUtils.getBean(serviceClass);
    }

}